package com.woman.beautylive.presentation.ui.main.find.pengyouquan;

import com.woman.beautylive.data.bean.BaseResponse;
import com.woman.beautylive.presentation.ui.base.BaseObserver;
import com.woman.beautylive.presentation.ui.base.BasePresenter;
import com.woman.beautylive.presentation.ui.main.find.paihangbangbean.DongTaiDetailBean;
import com.woman.beautylive.presentation.ui.main.find.paihangbangbean.DongTaiListBean;
import com.woman.beautylive.presentation.ui.main.find.paihangbangbean.MyDongTaiBean;

import java.util.List;

import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by admin on 2016/9/22.
 */
public class DongtaiPresenter extends BasePresenter<PublishInterFace> {

    DongtaiManager dongtaiManager;
    public DongtaiPresenter(PublishInterFace uiInterface) {
        super(uiInterface);
        dongtaiManager=new DongtaiManager();
    }

    public void getMyDongTaiList(String token,String page,String pagesize){
        Subscription subscription = dongtaiManager.getMyDongTaiLieBiao(token,page,pagesize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<BaseResponse<List<MyDongTaiBean>>>(getUiInterface()) {
                    @Override
                    public void onSuccess(BaseResponse<List<MyDongTaiBean>> response) {
                        System.out.println(response.getData()+"我的动态列表");
                        getUiInterface().showMyDongTaiList(response.getData());
//                        List<MeiLiBangBean> list = response;
//                        if (list==null ){
//                            getUiInterface().showEmptyResult();
//                        }
//                        else {
//                            getUiInterface().showData(list);
//                        }
                    }
                });
        addSubscription(subscription);
    }

    public void getDongTaiList(String token,String page,String pagesize){
        Subscription subscription = dongtaiManager.getDongTaiLieBiao(token, page, pagesize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<BaseResponse<DongTaiListBean>>(getUiInterface()) {
                    @Override
                    public void onSuccess(BaseResponse<DongTaiListBean> response) {
                        System.out.println(response.getData()+"我的动态列表");
                        getUiInterface().showDongtaiList(response.getData());
//                        List<MeiLiBangBean> list = response;
//                        if (list==null ){
//                            getUiInterface().showEmptyResult();
//                        }
//                        else {
//                            getUiInterface().showData(list);
//                        }
                    }
                });
        addSubscription(subscription);
    }

    public void getDongTaiDetail(String token,String pid,String max_like ,String max_reply){
        Subscription subscription = dongtaiManager.getDongTaiDetail(token, pid, max_like, max_reply)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<BaseResponse<DongTaiDetailBean>>(getUiInterface()) {
                    @Override
                    public void onSuccess(BaseResponse<DongTaiDetailBean> response) {
                        System.out.println(response.getData()+"我的动态列表");
                        getUiInterface().getDetailData(response.getData());
//                        List<MeiLiBangBean> list = response;
//                        if (list==null ){
//                            getUiInterface().showEmptyResult();
//                        }
//                        else {
//                            getUiInterface().showData(list);
//                        }
                    }
                });
        addSubscription(subscription);
    }
    public void getHuiFuList(String token,String pid,String pageNo ,String pageSize){
        Subscription subscription = dongtaiManager.getHuiFuList(token, pid, pageNo, pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<BaseResponse<DongTaiListBean.DongTaiItem.ReplyList>>(getUiInterface()) {
                    @Override
                    public void onSuccess(BaseResponse<DongTaiListBean.DongTaiItem.ReplyList> response) {
                        System.out.println(response.getData() + "我的动态列表");
                        getUiInterface().getReplyList(response.getData());
                    }
                });
        addSubscription(subscription);
    }
    public void getDianZanList(String token,String pid,String pageNo ,String pageSize){
        Subscription subscription = dongtaiManager.getDianZanList(token, pid, pageNo, pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<BaseResponse<DongTaiListBean.DongTaiItem.ReplyList>>(getUiInterface()) {
                    @Override
                    public void onSuccess(BaseResponse<DongTaiListBean.DongTaiItem.ReplyList> response) {
                        System.out.println(response.getData() + "我的动态列表");
                        getUiInterface().getDianZanList(response.getData());
                    }
                });
        addSubscription(subscription);
    }
}
